// components/nav-bar/nav-bar.js
Component({
    externalClasses: ['custom-class'],
    properties: {
        title: {
            type: String,
            value: '',
        },
        hasBack: {
            type: Boolean,
            value: true,
        },
        background: {
            type: String,
            value: '#fff',
        },
        border: {
            type: Boolean,
            value: false,
        },
        color: {
            type: String,
            value: '#000',
        },
        zIndex: {
            type: Number,
            value: 1
        }
    },
    data: {},
    methods: {
        onClickLeft() {
            this.triggerEvent('beforeBack');
            wx.navigateBack();
        },
        getHeight() {
            return new Promise(resolve => {
                wx.createSelectorQuery()
                    .in(this)
                    .select('#nav-bar')
                    .boundingClientRect(res => {
                        resolve(res.height);
                    })
                    .exec();
            });
        },
    },
});